<?php

namespace App\Http\Controllers\H5;


use App\Traits\Wechat\WechatPayManagers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class PayController extends BaseController
{

    use WechatPayManagers;

    public function getConfig(Request $request)
    {
        $order_id = $request->input('order_id');
        $order = $this->user()->boughts()->find($order_id);

        if ($order) {
            if ($order->trade_status == 1)
            {
                return $this->getPayConfig($order, $this->oauthUser->openid());
            }
            return ajaxError(201, '订单已支付');
        } else {
            return ajaxError(404, 'order not found');
        }
    }
}
